﻿using System.ComponentModel;
using System.Windows;
using MvvmOrm.Models;

namespace MvvmOrm
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            DataContext = new MainViewModel();
            InitializeComponent();
        }

        void window_Closing(object sender, CancelEventArgs e)
        {
            var vm = (MainViewModel)DataContext;
            if (vm.IsOpen) {
                vm.CloseCmd.Execute();
                if (vm.IsOpen)
                    e.Cancel = true;
            }
        }
    }
}
